<?php

namespace App\Store\Validate\Goods;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class GoodsGlodprice extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];


    public function __construct($doaction = 'maintenance')
    {
        if ($doaction == 'maintenance') {//金价维护
            $this->rule = [
                'store_ids'=>'required',
                'goods_category_name'=>'required',
            ];
            $this->message = [
                'store_ids.required' => '门店未选择',
                'goods_category_name.required' => '商品类别未选择',
            ];
        }elseif ($doaction == 'dopostbatchadd') {//批量新增
            $this->rule = [
                'store_id'=>'required|integer|gt:0',
                'goods_category_ids'=>'required',
            ];
            $this->message = [
                'store_id.required' => '门店未选择',
                'store_id.integer' => '门店参数错误',
                'store_id.gt' => '门店参数错误',
                'goods_category_ids.required' => '商品类别未选择',
            ];
        } elseif ($doaction == 'edit') {//编辑单条数据
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'back_company_price' => 'required|integer',
                'sales_price' => 'required|integer',
                'old_recovery_price' => 'required|integer',
                'old_goods_workfee' => 'required|integer',
                'date_str' => 'required|date',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'back_company_price.required' => '返厂金价不能为空',
                'back_company_price.integer' => '返厂金价必须是数字',
                'sales_price.required' => '销售牌价不能为空',
                'sales_price.integer' => '销售牌价必须是数字',

                'old_recovery_price.required' => '旧料回收价不能为空',
                'old_recovery_price.integer' => '旧料回收价必须是数字',

                'old_goods_workfee.required' => '折旧工费不能为空',
                'old_goods_workfee.integer' => '折旧工费必须是数字',

                'date_str.required' => '日期未选择',
                'date_str.date' => '日期格式不对',
            ];
        }else if($doaction=='dopostcopy'){
            $this->rule = [
                'choose_date' => 'required|date',
                'target_date_start' => 'required|date',
                'target_date_end' => 'required|date',
            ];
            $this->message = [
                'choose_date.required' => '指定时间未选择',
                'choose_date.date' => '指定时间格式不对',
                'target_date_start.required' => '同步金价开始时间未选择',
                'target_date_start.date' => '同步金价开始时间格式不对',
                'target_date_end.required' => '同步金价结束时间未选择',
                'target_date_end.date' => '同步金价结束时间格式不对',
            ];
        }
    }
}
